/**
 * This is the old interactive item in the last iteration
 */
package oop.core.item;

import oop.core.entity.Occupation;
import oop.core.entity.Stats;
import oop.core.visitors.*;

/**
 * NonTrapItem implements InteractiveItem
 * Items that are interactive on the map
 *
 */
public class NonTrapItem extends InteractiveItemVisitable
{
	private Requirements req;
	private boolean	state;
	private String activatedImageID;
	private String name;
	private String imageID;
	
	/**
	 * NonTrapItem Constructor
	 */
	public NonTrapItem(String name, String imageID, Requirements req, boolean state, String activatedImageID)
	{
		super(name, imageID);
		this.req = req;
		this.state = state;
		this.activatedImageID = activatedImageID;
	}

	/**
	 * get/set methods for requirement, state, activatedImageID
	 */
	public void setState(boolean state) {
		this.state = state;
	}

	public boolean getState() {
		return state;
	}

	public void setReq(Requirements req) {
		this.req = req;
	}

	public Requirements getRequirement() {
		return req;
	}

	public void setActivatedImageID(String ID){
		this.activatedImageID = ID;
	}

	public String getImageID(){
		return state ? this.activatedImageID : super.imageID;
	}

	/**
	 * Toggles the item's state.
	 * @return void
	 */
	public void activateItem(Stats derivedStats,Inventory inventory ){
		System.out.println("Are my requirements met?"  + checkRequirements(derivedStats, inventory));
		if(checkRequirements(derivedStats, inventory))
		{
			this.state = true;
		}
	}

	/**
	 * Checks if the entity meets the NonTrapItem's requirements.
	 * @param stats
	 * @param inventory
	 * @return boolean
	 */
	public boolean checkRequirements(Stats stats, Inventory inventory)
	{
		System.out.println("Stat met?" + checkStatsRequirements(stats));
		System.out.println("Inventory met?" + checkItemRequirements(inventory));
		return checkStatsRequirements(stats) && checkItemRequirements(inventory);
	}

	/**
	 * Helper method for checkRequirements that just compares stats.
	 * @param stats
	 * @return boolean
	 */
	public boolean checkStatsRequirements(Stats stats)
	{
		return req.areStatRequirementsMet(stats);
	}

	/**
	 * Helper method for checkRequirements that just compares the inventory.
	 * @param inventory
	 * @return boolean
	 */
	public boolean checkItemRequirements(Inventory inventory){
		return req.areItemRequirementsMet(inventory);
	}

	public String toString() {
		return "NonTrapItem [req=" + req + ", state=" + state
			+ ", activatedImageID=" + activatedImageID + "]";
	}
	
	public void accept(InteractiveItemVisitor visitor){
		visitor.visitNonTrap(this);
	}

}
